<?php

class union 
{
	function __construct() 
	{
		changeDbh("union");
	}
    function __destruct()
	{
		changeDbh();
    }
	function getSiteInfo()
	{
		$site_domain = $_SERVER['HTTP_HOST'];
		$sql = "select * from u_content_site as s left join u_content_site_info as i on s.site_id=i.site_id where  site_domain='".$site_domain."' ";
		$res = sql_get_one($sql,__LINE__);
		$res['login_back_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$res['site_domain'] = "http://".$site_domain;
		$res['main_domain'] = "http://www.".$res['main_domain'];
		return $res;
	}
	function getNews($sortid=1, $gsortid=1, $limit=5, $start=0)
	{
		if (intval($sortid)) {
			$where .=" and arti_sortid=$sortid";
		}
		if (intval($gsortid)) {
			$where .=" and arti_gsortid=$gsortid";
		}
		if ($start) {
			$limit = "$start,$limit";
		}
		$sql = "select article_id, title, time from u_content_article where 1 ".$where." order by time desc limit $limit";
        $res = sql_get_arr($sql,__LINE__);
		if($res)
		{
            $length = count($res)-1;
			$arrList = array();
			for($i=0;$i<$length;$i++)
			{
                $res[$i]['time'] = date("Y-m-d",$res[$i]['time']);
				$res[$i]['title'] = globalCutStr($res[$i]['title'],10);
				$res[$i]['news_url'] = "../news/news_content.php?aid=".$res[$i]['article_id'];
				$arrList[] = $res[$i];
			}
		}
		return $arrList;
	}	
}

?>